import React ,{ useState} from 'react';


function App(){
    const [ info , setInfo ] = useState({
        name:'琪琪先生',
        age: 28
    })
   const changeInfo = () =>{
        setInfo((prevInfo)=>{
           const newInfo = {
               name:'光头先生',
               age:34,
               hobby:'basketball'
           }
           return Object.assign(newInfo, prevInfo)
        //    return { ...prevInfo, ...newInfo}
        });
      
    }

    return (
        <>
         <h1>welcome to reactHooks </h1>
         <button onClick={ changeInfo }>change info</button>
        </>
    )
}

export default App;